#include "mcp4017.h"

#include "i2c_hal.h"

void MCP4017_Write(uint8_t data)
{
    I2CStart();
    I2CSendByte(0x5E);
    I2CWaitAck();
    I2CSendByte(data);
    I2CWaitAck();
    I2CStop();
}

uint8_t MCP4017_Read(void)
{
    uint8_t ret_val = 0;

    I2CStart();
    I2CSendByte(0x5F);
    I2CWaitAck();
    ret_val = I2CReceiveByte();
    I2CSendNotAck();
    I2CStop();

    return ret_val;
}
